<template>
  <section class="jumbotron">
    <h3 class="jumbotron-heading">Search Github Users</h3>
    <div>
      <input type="text" placeholder="enter the name you search"
             v-model.trim.lazy="searchName"/>
      <button @click="search">Search</button>
    </div>
  </section>
</template>

<script>
    import {mapActions} from "vuex";
    export default {
        name: "search",
        computed:{
          searchName:{
            get(){return this.$store.state.searchName},
            set(val){
              //val 用户输入的最新的用户名
              //拿到用户的数据 并且将用户的数据入vuex库
              //action - mutation - state
              this.$store.dispatch("searchName",val)
            }
          }
        },
        methods:{
          ...mapActions(["search"])
        }
    }
</script>

<style scoped>

</style>
